<template>
  <div class="news-box">
    <div class="top_linkdre container">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/help_center/h_home' }">帮助中心</el-breadcrumb-item>
        <el-breadcrumb-item>详情</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="news_txtbox container">
      <div class="article-container" id="article-container">
        <section class="article-sidebar">
          <section class="section-articles collapsible-sidebar">
            <h3 class="collapsible-sidebar-title sidenav-title">系统消息</h3>
            <ul class="list_left" >
              <li
                v-for="(item,index) in qList.slice(0,8)"
                :key='index' 
                @click="getIDinfo(item)"
              >
              <p v-text="item.title" class="w350" :class="qid==item.autoid?'active':''"></p>
              </li>
            </ul>
          </section>
        </section>

        <article class="article">
          <header class="article-header">
            <h1 :title="qItem.title" class="article-title">
              {{qItem.title}}
            </h1>

            <div class="article-author">
              <div class="avatar article-avatar">
                <span class="icon-agent"></span>

                <img
                  src="../../assets/images/user/user_icon.png"
                  alt="Avatar"
                  class="user-avatar"
                />
              </div>
              <div class="article-meta">
                Admin
                <ul class="meta-group m-top-5">
                  <li class="meta-data">更新于</li>
                  <li class="meta-data">
                    <span  data-datetime="relative">{{qItem.wdate}}</span>
                  </li>
                </ul>
              </div>
            </div>
          </header>

          <section class="article-info">
            <div class="article-content">
              <div class="article-body">
                <article v-html="qItem.reply">
                </article>
              </div>

              <div class="article-attachments">
                <ul class="attachments"></ul>
              </div>
            </div>
          </section>

          <footer>
            <div class="article-footer">
              <div class="article-share">
                <ul class="share flex">
                  <li>
                    <i class="iconfont icon-facebook"></i>
                    <a  href="" class="share-facebook">Facebook</a>
                  </li>
                  <li>
                    <i class="iconfont icon-twitter"></i>
                    <a  href=""  class="share-twitter">Twitter</a>
                  </li>
                  <li>
                    <i class="iconfont icon-weibo"></i>
                    <a  href=""  class="share-linkedin">LinkedIn</a>
                  </li>
                </ul>
              </div>
            </div>

            <div class="article-votes mtop10">
              <span class="article-votes-question">这篇文章有帮助吗？</span>
            </div>
            <div class="article-more-questions mtop10">
              还有其它问题？
              <a href="javascript:void(0)">提交请求</a>
            </div>

            <div class="article-return-to-top mtop10">
              <a href="#article-container">
                返回页首
                <span class="icon-arrow-up"></span>
              </a>
            </div>
          </footer>

          <section class="article-relatives">
            <section class="recent-articles">
              <h3 class="recent-articles-title">相关文章</h3>
              <ul>
                <li v-for="(item, index)  in qList" :key="index">
                <a  href="javascript:void(0)"  class=" " > 
                  <p>{{item.title}}</p>
                </a>
              </li>
              </ul>
            </section>
          </section>
          <div class="article-comments" id="article-comments">
            <section class="comments">
              <header class="comment-overview">
                <h3 class="comment-heading">评论</h3>
                <p class="comment-callout">0 条评论</p>
              </header>

              <ul id="comments" class="comment-list"></ul>

              <p class="comment-callout">文章评论已关闭。</p>
            </section>
          </div>
        </article>
      </div>
    </div>
  </div>
</template>
<script>
import questionModel from "@/model/questionModel";
let { faqList } = questionModel;
export default {
  data() {
    return {
      banner: require("@/assets/images/help/bangzhu_banner.png"),
      currentId: 1,
      currentItem: null,
      qList: null,
      qItem: null,
      qid: null,
      breadNavItem: {}
    };
  },
  mounted() {
    let params = this.getParams();
    if (params) {
      this.breadNavItem = params;
      this.qid = params.qid;
    }
    this.getQlist();
  },
  methods: {
    getParams() {
      return Object.assign({}, this.$route.query);
    },
    getQlist() {
      if (faqList) {
        this.qList = faqList;
        this.getQItem(this.qList, this.qid);
      } else {
        this.request(this.api.articles,{pagesize:'1',pagecode:'40'}).then(res => {
          console.log(`问题列表:${JSON.stringify(res)}`);
          if (res && res.code != "0") return this.getDataFaild(res.msg);
          if (res.data && res.data[0]) {
            this.qList = questionModel.faqList = res.data;
            this.getQItem(this.qList, this.qid);
          }
        });
      }
    },
    // 获取问题详情
    getQItem(arrList, id) {
      arrList.map(item => {
        if (item.autoid && item.autoid == id) {
          this.qItem = item;
          console.log(this.qItem);
          
        }
      });
    },
    getIDinfo(item){
      console.log(item.autoid);
      this.qid=item.autoid;
      this.getQItem(this.qList,this.qid);
    }
  }
};
</script>

<style lang="scss" scoped>
.container {
  min-height: calc(100% - 294px);
  padding: 30px 0;
  width: 77%;
  margin: 0 auto;
  .el-main {
    padding-top: 0;
  }
}
.news-box{
  .news_txtbox{
  .article-container {
    display: flex;
    // flex-direction: column;
  }
  .article-sidebar {
    margin-bottom: 20px;
    padding: 0;
  }
  .collapsible-sidebar {
    flex: 1;
    // max-height: 45px;
    overflow: hidden;
    padding: 0px;
    position: relative;
  }
  .collapsible-sidebar-title {
    margin-top: 0;
  }
  .sidenav-title {
      font-size: 15px;
      position: relative;
      font-weight: 600;
      padding-bottom: 10px;
      margin-bottom: 10px;
      border-bottom: 2px solid #eeeeee;
  }
  .artactive{
    background-color: #357ce1;
    color: #FFFFFF;
    text-decoration: none;
  }
  .sidenav-item.artactive, .sidenav-item:hover {
    background-color: #357ce1;
    color: #FFFFFF;
    text-decoration: none;
  }
  // 左侧列表
  .list_left{
    li{
      cursor: pointer;margin-bottom: 10px;
      p{line-height: 18px;padding: 5px 2px;}
      .active{background: #357ce1;color: #FFFFFF;}
    }
  }
  .sidenav-item {
      border-radius: 4px;
      color: rgba(28, 36, 44, 1);
      display: block;
      font-weight: 300;
      margin-bottom: 10px;
      padding: 10px;
  }
  // 右侧
  .article-author{
    display: flex;margin-top: 12px;
    img{width: 35px;height: 35px;border-radius: 50%;}
    .article-meta{margin-left: 15px;}
    .meta-group{display: flex;}
  }
  .article{
    .article-header{
      h1{font-size: 16px;font-weight: 600;}
    }
    .mtop10{
      margin: 10px 0;
    }
  }
  .article-body{
    min-height: 300px;
  }
  .article-content {
    line-height: 1.6;
    margin: 20px 0;
    word-wrap: break-word;
  }
  .article-footer{
    .share{
      li{margin-right: 20px;}
    }
  }
  }
  // 底部
  .article-relatives {
    border-top: 1px solid #ddd;
    display: flex;
    // flex-direction: column;
    padding: 20px 0;
    .recent-articles li, .related-articles li {
        margin-bottom: 15px;
    }
    .recent-articles{flex: 1;}
    .recent-articles-title,.related-articles-title{font-weight: bold;font-size: 16px;margin-bottom: 10px;}
  }
  // 评论
  .article-comments{
    .comment-heading{font-size: 14px;font-weight: bold;}
    .comment-callout{line-height: 30px;}
  }
  a {
        color: rgba(53, 124, 225, 1);
        text-decoration: none;
  }
}
@media (min-width: 1024px){
  // .article-container {
  //     flex-direction: row;
  // }

  .article-sidebar {
    border: 0;
    flex: 0 0 20%;
    height: auto;
  }
  .article {
    flex: 1 0 66%;
    max-width: 66%;
    min-width: 640px;
    padding: 0 30px;
  }
}
@media (min-width: 768px){
  .article-relatives {
      flex-direction: row;
  }
}
.user-avatar{width: 32px;}
</style>
